<?php

class Home extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->helper('url');
        $this->load->model("tree_m");
        header('Content-Type: text/html; charset=utf-8');
    }

    // home page
    public function index() {
        $data = array();
        $list_tree = $this->tree_m->getTree();
        foreach($list_tree as $value){
            if($value["Type"] == Tree_m::TREE_TYPE_1)
                $data['list_tree1'][] = $value;
            elseif($value["Type"] == Tree_m::TREE_TYPE_2)
                $data['list_tree2'][] = $value;
            elseif($value["Type"] == Tree_m::TREE_TYPE_3)
                $data['list_tree3'][] = $value;
            elseif($value["Type"] == Tree_m::TREE_TYPE_4)
                $data['list_tree4'][] = $value;
        }
//        echo 'data: <pre>';
//        print_r($data);
        $this->load->view("home_v", $data);
    }
    
        // cay de ban
    public function treeShop1() {
        $data = array();
        $data['list_tree'] = $this->tree_m->getTree(Tree_m::TREE_TYPE_1);
        $this->load->view("treeshop1_v", $data);
    }
    
        // cay dang nay mam
    public function treeShop2() {
        $data = array();
        $data['list_tree'] = $this->tree_m->getTree(Tree_m::TREE_TYPE_2);
        $this->load->view("treeshop2_v", $data);
    }
    
        // cay trong nuoc
    public function treeShop3() {
        $data = array();
        $data['list_tree'] = $this->tree_m->getTree(Tree_m::TREE_TYPE_3);
        $this->load->view("treeshop3_v", $data);
    }
    // cay cho cac ngay le
    public function treeShop4() {
        $data = array();
        $data['list_tree'] = $this->tree_m->getTree(Tree_m::TREE_TYPE_4);
        $this->load->view("treeshop4_v", $data);
    }

    // detail a tree
    public function detail($macay = NULL) {
        $data = array();
        $tree_info = $this->tree_m->get_record($macay);
        $data['tree'] = $tree_info; 
        $this->load->view("detail_v", $data);
    }
    
    /*
     * function van chuyen , ship hang
     */
    function ship_fee(){
        $this->load->view('ship_fee_v');
    }

}

?>